﻿#include "CPolPoint.h"

CPolPoint::CPolPoint()
{
	m_dPointLocation = 0;
	m_dPointX = 0;
	m_dPointY = 0;
	m_dPointZ = 0;
	m_nIsChargePoint = 1;
	m_nPointStatus = 0;
	m_nRollerCode = 0;
	m_sRollerDesc = "";
}

CPolPoint::~CPolPoint()
{
}

void CPolPoint::resetData()
{

}

int CPolPoint::getItemMaxIndex()
{
	int nMaxIndex = 0;
	for (QMap<QString, CPolItem*>::iterator itor = m_mapPolItem.begin(); itor != m_mapPolItem.end(); itor++)
	{
		CPolItem* pItem = itor.value();
		if (pItem->m_nIndex >= nMaxIndex)
		{
			nMaxIndex = pItem->m_nIndex;
		}
	}
	return nMaxIndex;
}


void CPolPoint::copyData(CPolPoint *pPolPoint)
{
	//首先先将传进来的类中的数据清空
	pPolPoint->resetData();

	//复制常规的数据
	pPolPoint->m_sPointGuid = m_sPointGuid;
	pPolPoint->m_sPointName = m_sPointName;
	pPolPoint->m_sPolAreaGuid = m_sPolAreaGuid;
	pPolPoint->m_sGuid = m_sGuid;
	pPolPoint->m_dPointLocation = m_dPointLocation;
	pPolPoint->m_dPointX = m_dPointX;
	pPolPoint->m_dPointY = m_dPointY;
	pPolPoint->m_dPointZ = m_dPointZ;
	pPolPoint->m_nIsChargePoint = m_nIsChargePoint;
	pPolPoint->m_nPointStatus = m_nPointStatus;
	pPolPoint->m_nRollerCode = m_nRollerCode;
	pPolPoint->m_sRollerDesc = m_sRollerDesc;
	for (QMap<QString, CPolItem*>::iterator itor = m_mapPolItem.begin(); itor != m_mapPolItem.end(); itor++)
	{
		if (itor.value()->m_nDevType == 0)
		{
			CPolItemSensor* pPolItem = new CPolItemSensor();
			((CPolItemSensor *)itor.value())->copyData(pPolItem);
			pPolPoint->m_mapPolItem.insert(pPolItem->m_sItemGuid, pPolItem);
		}
		else if (itor.value()->m_nDevType == 1)
		{
			CPolItemCamer* pPolItem = new CPolItemCamer();
			((CPolItemCamer *)itor.value())->copyData(pPolItem);
			pPolPoint->m_mapPolItem.insert(pPolItem->m_sItemGuid, pPolItem);
		}
	}

}